#!/usr/bin/env python
# encoding: utf-8
"""
 @author: y
 @contact: you30l@126.com
 @time: --2021/3/31 16:56
 @desc: description
"""

import requests
from jsonpath import jsonpath

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36 Edg/89.0.774.63',
}
# 请求代理池地址，获取一个代理
proxy_url = 'http://localhost:5555/random'
proxy_ip = requests.get(proxy_url).text


proxies = {
    'http': 'http://' + proxy_ip
}

httbin_url = 'http://www.httpbin.org/get'
response = requests.get(httbin_url, headers=headers, proxies=proxies)
print("状态码：", response.status_code)
print("代理池IP：", proxy_ip)
print(jsonpath(response.json(), '$..origin'))
